<%- getApiDefine(api) %>

#include "playfab/PlayFab<%- api.name %>Api.h"
#include "playfab/PlayFabHttp.h"
#include "playfab/PlayFabSettings.h"

namespace PlayFab
{
    using namespace <%- api.name %>Models;

    size_t PlayFab<%- api.name %>API::Update()
    {
        return PlayFabHttp::Get().Update();
    }

    void PlayFab<%- api.name %>API::ForgetAllCredentials()
    {
        return PlayFabSettings::ForgetAllCredentials();
    }

    // PlayFab<%- api.name %> APIs
<% for (var callIdx = 0; callIdx < api.calls.length; callIdx++) { var apiCall = api.calls[callIdx]; %>
    void PlayFab<%- api.name %>API::<%- apiCall.name %>(
        <%- apiCall.request %>& request,
        ProcessApiCallback<<%- apiCall.result %>> callback,
        ErrorCallback errorCallback,
        void* customData
    )
    {
<%- getRequestActions("        ", apiCall) %>
        IPlayFabHttp& http = IPlayFabHttp::Get();
        auto requestJson = request.ToJson();
        http.AddRequest(L"<%- apiCall.url %>", <%- getAuthParams(apiCall) %>, requestJson, On<%- apiCall.name %>Result, SharedVoidPointer((callback == nullptr) ? nullptr : new ProcessApiCallback<<%- apiCall.result %>>(callback)), errorCallback, customData);
    }

    void PlayFab<%- api.name %>API::On<%- apiCall.name %>Result(CallRequestContainer& request)
    {
        <%- apiCall.result %> outResult;
        outResult.FromJson(request.errorWrapper.Data);
        outResult.Request = request.request;
<%- getResultActions("        ", apiCall) %>
        auto internalPtr = request.successCallback.get();
        if (internalPtr != nullptr)
        {
            auto callback = (*static_cast<ProcessApiCallback<<%- apiCall.result %>> *>(internalPtr));
            callback(outResult, request.customData);
        }
    }
<% } %><% if (hasClientOptions) { %>
    // Private PlayFabClientAPI specific
    bool PlayFabClientAPI::IsClientLoggedIn()
    {
        return !PlayFabSettings::clientSessionTicket.empty();
    }

    void PlayFabClientAPI::MultiStepClientLogin(bool needsAttribution)
    {
        if (needsAttribution && !PlayFabSettings::disableAdvertising && PlayFabSettings::advertisingIdType.length() > 0 && PlayFabSettings::advertisingIdValue.length() > 0)
        {
            AttributeInstallRequest request;
            if (PlayFabSettings::advertisingIdType == PlayFabSettings::AD_TYPE_IDFA)
                request.Idfa = ShortenString(PlayFabSettings::advertisingIdValue);
            else if (PlayFabSettings::advertisingIdType == PlayFabSettings::AD_TYPE_ANDROID_ID)
                request.Adid = ShortenString(PlayFabSettings::advertisingIdValue);
            else
                return;
            AttributeInstall(request, nullptr, nullptr);
        }
    }
<% } %>}

#endif
